//
//  AcitvityCell.m
//  DSYDouban
//
//  Created by dllo on 15/12/31.
//  Copyright © 2015年 lanou3g. All rights reserved.
//

#import "ActivityCell.h"

@interface ActivityCell ()

//@property (nonatomic, retain) UILabel *titleLabel;
//
//@property (nonatomic, retain) UILabel *start_to_endTimeLabel;
//
//@property (nonatomic, retain) UILabel *addressLabel;
//
//@property (nonatomic, retain) UILabel *category_nameLable;
//
//@property (nonatomic, retain) UILabel *wisher_countLabel;
//
//@property (nonatomic, retain) UILabel *participant_countLable;
//
//@property (nonatomic, retain) UIImageView *imgView;

@property (nonatomic, retain) UIImageView *bigBackgroundView;

@property (nonatomic, retain) UIImageView *contentBackgroundView;

@property (nonatomic, retain) UIImageView *durationImageView;

@property (nonatomic, retain) UIImageView *addressImageView;

@property (nonatomic, retain) UIImageView *categoryImageView;

@property (nonatomic, retain) UILabel *wisherLable;

@property (nonatomic, retain) UILabel *participantLabel;

@end

@implementation ActivityCell

- (void)dealloc
{
    [_bigBackgroundView release];
    [_titleNameLabel release];
    [_contentBackgroundView release];
    
    
    [_durationImageView release];
    [_addressImageView release];
    [_categoryImageView release];
    [_wisherLable release];
    [_participantLabel release];
    
    
    [_start_to_endTimeLabel release];
    [_addressLabel release];
    [_category_nameLable release];
    [_wisher_countLabel release];
    [_participant_countLable release];
    
    [_imgView release];
    
    [super dealloc];
}

- (instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self create];
    }
    return self;
}

- (void)create {
    
    // 整个cell的背景图片以及内容
    self.bigBackgroundView = [[UIImageView alloc] init];
    [self.contentView addSubview:_bigBackgroundView];
    [_bigBackgroundView release];
    
    self.titleNameLabel = [[UILabel alloc] init];
    [_bigBackgroundView addSubview:_titleNameLabel];
    [_titleNameLabel release];
    
    self.contentBackgroundView = [[UIImageView alloc] init];
    [_bigBackgroundView addSubview:_contentBackgroundView];
    [_contentBackgroundView release];
    
    /////////////////////////////////////////////////////
    // 内容背景图片上显示的信息 (固定不变的信息)
    self.durationImageView = [[UIImageView alloc] init];
    [_contentBackgroundView addSubview:_durationImageView];
    [_durationImageView release];
    
    self.addressImageView = [[UIImageView alloc] init];
    [_contentBackgroundView addSubview:_addressImageView];
    [_addressImageView release];
    
    self.categoryImageView = [[UIImageView alloc] init];
    [_contentBackgroundView addSubview:_categoryImageView];
    [_categoryImageView release];
    
    self.wisherLable = [[UILabel alloc] init];
    [_contentBackgroundView addSubview:_wisherLable];
    [_wisherLable release];
    
    self.participantLabel = [[UILabel alloc] init];
    [_contentBackgroundView addSubview:_participantLabel];
    [_participantLabel release];
    
    //  内容背景图上显示的可变动的信息
    self.start_to_endTimeLabel = [[UILabel alloc] init];
    [_contentBackgroundView addSubview:_start_to_endTimeLabel];
    [_start_to_endTimeLabel release];
    
    self.addressLabel = [[UILabel alloc] init];
    [_contentBackgroundView addSubview:_addressLabel];
    [_addressLabel release];
    
    self.category_nameLable = [[UILabel alloc] init];
    [_contentBackgroundView addSubview:_category_nameLable];
    [_category_nameLable release];
    
    self.wisher_countLabel = [[UILabel alloc] init];
    [_contentBackgroundView addSubview:_wisher_countLabel];
    [_wisher_countLabel release];
    
    self.participant_countLable = [[UILabel alloc] init];
    [_contentBackgroundView addSubview:_participant_countLable];
    [_participant_countLable release];
    
    self.imgView = [[UIImageView alloc] init];
    [_contentBackgroundView addSubview:_imgView];
    [_imgView release];
    
}

- (void)layoutSubviews
{
    // 调用父类的自动调整布局方法
    [super layoutSubviews];
    
    
    _bigBackgroundView.frame = CGRectMake(5, 6, self.contentView.frame.size.width - 10, self.contentView.frame.size.height - 12);
    _bigBackgroundView.image = [UIImage imageNamed:@"bg_eventlistcell.png"];
    
    CGFloat big_W = _bigBackgroundView.frame.size.width;
    CGFloat big_H = _bigBackgroundView.frame.size.height;
    
    _titleNameLabel.frame = CGRectMake(5, 5, big_W - 10, 35);
//    _titleNameLabel.backgroundColor = [UIColor greenColor];
    
    _contentBackgroundView.frame = CGRectMake(0, _titleNameLabel.frame.size.height + 5, big_W, big_H - _titleNameLabel.frame.size.height - 5);
    _contentBackgroundView.image = [UIImage imageNamed:@"bg_share_large.png"];
    
    ///////////////////////////////
    CGFloat content_W = _contentBackgroundView.frame.size.width;
    CGFloat content_H = _contentBackgroundView.frame.size.height;
    //////////////////////////////
    
    _durationImageView.frame = CGRectMake(5, 5, 25, 25);
    _durationImageView.image = [UIImage imageNamed:@"icon_date.png"];
    
    _start_to_endTimeLabel.frame = CGRectMake(35, 5, content_W * 0.55, 25);
//    _start_to_endTimeLabel.backgroundColor = [UIColor greenColor];
    _start_to_endTimeLabel.font = [UIFont systemFontOfSize:15.0];
    
   
    //////////////////////////////
    _addressImageView.frame = CGRectMake(5, _durationImageView.frame.origin.y + 25 + 5, 25, 25);
    _addressImageView.image = [UIImage imageNamed:@"icon_spot.png"];
    
    
    _addressLabel.frame = CGRectMake(35, _addressImageView.frame.origin.y, content_W * 0.55, 25);
    _addressLabel.font = [UIFont systemFontOfSize:15.0];
//    _addressLabel.backgroundColor = [UIColor greenColor];

    /////////////////////////////
    _categoryImageView.frame = CGRectMake(5, _addressImageView.frame.origin.y + 30, 25, 25);
    _categoryImageView.image = [UIImage imageNamed:@"icon_catalog.png"];
    
    _category_nameLable.frame = CGRectMake(35, _categoryImageView.frame.origin.y, content_W * 0.55, 25);
//    _category_nameLable.backgroundColor = [UIColor greenColor];
    _category_nameLable.font = [UIFont systemFontOfSize:15.0];
    
    
    ////////////////////////////////
    _wisherLable.frame = CGRectMake(15, content_H - 35, 40, 25);
    _wisherLable.text = @"感兴趣:";
    _wisherLable.font = [UIFont systemFontOfSize:12.0];
    
    _wisher_countLabel.frame = CGRectMake(55, content_H - 35, content_W * 0.15, 25);
//    _wisher_countLabel.backgroundColor = [UIColor greenColor];
    _wisher_countLabel.font = [UIFont systemFontOfSize:12.0];
    _wisher_countLabel.textColor = [UIColor redColor];
    
    
    _participantLabel.frame = CGRectMake(_wisher_countLabel.frame.origin.x + content_W * 0.15 + 5, content_H - 35, 30, 25);
    _participantLabel.text = @"参加:";
    _participantLabel.font = [UIFont systemFontOfSize:12.0];
    
    _participant_countLable.frame = CGRectMake(_participantLabel.frame.origin.x + 35, content_H - 35, content_W * 0.15, 25);
//    _participant_countLable.backgroundColor = [UIColor greenColor];
    _participant_countLable.font = [UIFont systemFontOfSize:12.0];
    _participant_countLable.textColor = [UIColor redColor];
    
    
    ////////////////////////////
    _imgView.frame = CGRectMake(content_W * 0.7, 5, content_W * 0.3 - 5, content_H - 10);
//    _imgView.backgroundColor = [UIColor greenColor];
    
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
